package com.bjshiwei.zhengu.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bjshiwei.zhengu.R;

/**
 * 作者：Administrator on 2017/2/14 0014 09:46
 * 邮箱：sanjins@126.com
 */


public class CustomCircleView extends RelativeLayout{
    private TextView mTextViewName;
    private TextView mTextViewScore;
    public CustomCircleView(Context context) {
        this(context,null);
    }

    public CustomCircleView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context,attrs);
    }

    public CustomCircleView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context,attrs);
    }

    private void init(Context context, AttributeSet attrs) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.custom_home_circle, null);
        mTextViewName = (TextView) inflate.findViewById(R.id.tv_circle_name);
        mTextViewScore = (TextView) inflate.findViewById(R.id.tv_circle_score);

        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CircleViewAttr);

        String score = (String) typedArray.getText(R.styleable.CircleViewAttr_text_score);
        if(!TextUtils.isEmpty(score)) {
            mTextViewScore.setText(score);
        }

        String name = (String) typedArray.getText(R.styleable.CircleViewAttr_text_name);
        if(!TextUtils.isEmpty(name)) {
            mTextViewName.setText(name);
        }
        typedArray.recycle();
    }

    public void setmTextViewName(String name){
        if(!TextUtils.isEmpty(name)) {
            mTextViewName.setText(name);
        }
    }

    public void setmTextViewScore(String score){
        if(!TextUtils.isEmpty(score)) {
            mTextViewScore.setText(score);
        }
    }


}
